﻿@{
    ViewData["Title"] = "StoryDetail";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model StorySeries;
<h2>详情<button class="btn btn-primary" style="float:right" onclick="ToList()">返回</button></h2>
<hr />

<div id="content" class="container">
    <h1>@Model.SeriesName</h1>
    <p>作者：@ViewBag.Author</p>
    <div class="col-md-8"><p>@Model.Text</p></div>
    <div class="col-md-4"><img src="@Model.IMG" /></div>

    @if (!ViewBag.HadAdd)
    {
        <button class="btn btn-primary" onclick="AddList()">添加到列表</button>
    }
</div>

<script>
    function ToList() {
        window.location.href = '/Main/StorySelect'
    }
    function AddList() {
        let SeriesID = '@Model.ID';
        $.post("/Main/AddList", { SeriesID: SeriesID }, function (data) {
            if (data == true) {
                window.location.reload();
            }
            else {
                alert("发生了一个错误！")
            }
            
        })
    }
</script>